package com.example.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author: Zeran
 * Date: 2024-05-26 16:20
 * Desc:
 */
@Configuration
public class MybatisPlusConfig {

	@Bean
	public MybatisPlusInterceptor getMybatisPlusInterceptor() {
		//	1.定义mp拦截器
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		//	2.添加分页拦截器
		interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
		// 3.添加乐观锁拦截器
		interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
		// 4.添加全局拦截插件（避免对重要数据进行误删除）
		// interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
		return interceptor;
	}

}
